﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

public partial class Control_btnPrevious : System.Web.UI.UserControl
{
    [Description("設定Button顯示名"), Category("MISAPP"), DefaultValue("")]
    public string Caption
    {
        set
        {
            btn.Text = value;
        }
        get
        {
            return btn.Text;
        }
    }

    [Description("設定網頁轉走前是否要帶參數在網址列"), Category("MISAPP"), DefaultValue("")]
    public string PageParameter
    {
        set;
        get;
    }

    [Description("設定回上頁的網頁名"), Category("MISAPP"), DefaultValue("")]
    public string PreviousPage
    {
        set;
        get;
    }

    public event EventHandler Click = null;

    protected void Page_Load(object sender, EventArgs e)
    {
  
    }

    //在轉出前先把要做的事解決
    protected void btn_Click(object sender, EventArgs e)
    {
        if (Click != null)
        {
            Click(sender, e);
        }     
        if (string.Empty != PreviousPage)
        {
            string page = PreviousPage;
            if (PageParameter != string.Empty)
            {
                page = string.Format("{0}?{1}"
                    , PreviousPage
                    , PageParameter
                    );
            }
            Server.Transfer(page);
        }
    }
}
